package io.fredia.femicro.gate.server;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.annotation.EnableScheduling;

import io.fredia.femicro.auth.client.EnableFeAuthClient;
import io.fredia.femicro.gate.ratelimit.EnableFeGateRateLimit;
import io.fredia.femicro.gate.ratelimit.config.IUserPrincipal;
import io.fredia.femicro.gate.server.config.UserPrincipal;
import io.fredia.femicro.gate.server.utils.DBLog;

/**
 * 启动网关
 * 
 * @author : Fredia
 * @since : 2018年3月13日
 * @version : v1.0.0
 */
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients({"io.fredia.femicro.auth.client.feign","io.fredia.femicro.gate.server.feign"})
@EnableZuulProxy
@EnableScheduling
@EnableFeAuthClient
@EnableFeGateRateLimit
public class GateBootstrap {
    public static void main(String[] args) {
        DBLog.getInstance().start();
        SpringApplication.run(GateBootstrap.class, args);
    }

    @Bean
    @Primary
    IUserPrincipal userPrincipal(){
        return new UserPrincipal();
    }
}
